package task.dataObjects
{
	import common.utils.DateManager;
	
	import mx.collections.ArrayCollection;
	[Bindable]
	public class TaskDetailDO
	{
		public var INTERNAL_TASK_LINE_NUM:String = "0";
		public var INTERNAL_TASK_NUM:String = "0";
		public var TASK_ID:String = "";
		public var TASK_TYPE:String = "";
		public var WAREHOUSE:String = "";
		public var COMPANY:String = "";
		public var ITEM:String = "";
		public var ITEM_DESC:String = "";
		public var TOTAL_QTY:Number = 0;
		public var FROM_QTY:Number = 0;
		public var TO_QTY:Number = 0;
		public var QUANTITY_UM:String = "";
		public var FROM_LOC:String = "";
		public var TO_LOC:String = "";
		public var FROM_LPN:String = "";
		public var TO_LPN:String = "";
		public var ATTRIBUTE_NUM:String = "";
		public var CONDITION:String = "";
		public var REFERENCE_NUM:String = "0";
		public var REFERENCE_NUM_TYPE:String = "";
		public var REFERENCE_LINE_NUM:String = "0";
		public var REFERENCE_ID:String = "";
		public var ASSIGNED_USER:String = "";
		public var INTERNAL_TASK_TYPE:String = "";
		public var ATTRIBUTE1:String = "";
		public var ATTRIBUTE2:String = "";
		public var ATTRIBUTE3:String = "";
		public var ATTRIBUTE4:String = "";
		public var ATTRIBUTE5:String = "";
		public var ATTRIBUTE6:String = "";
		public var ATTRIBUTE7:String = "";
		public var ATTRIBUTE8:String = "";
		public var USER_STAMP:String = "";
		public var DATE_TIME_STAMP:String = DateManager.GetTodayString();
		public var CURRENT_LOC:String = "";
		public var CURRENT_LPN:String = "";
		public var CONFIRM_QTY:String;
		public var ACTUAL_FROM_LOC:String = "";
		public var ACTUAL_FROM_LPN:String = "";
		public var ACTUAL_TO_LOC:String = "";
		public var ACTUAL_TO_LPN:String = "";
		public var INVENTORY_STS:String = "";
		public var INTERNAL_WAVE_NUM:Number = 0;
		public var REFERENCE_CONT_NUM:Number = 0;
		public var REFERENCE_REQ_NUM:Number = 0;
		public var CONFIRM_USER:String = "";

		public function TaskDetailDO(xmlObj:XML)
		{
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					//Use XML node name to reference matching property in value object
					if(itemProp.name() == "CURRENT_LOC"){
						this["CURRENT_LOC"] = itemProp;
						this["ACTUAL_FROM_LOC"] = itemProp;
					}
					else if(itemProp.name() == "CURRENT_LPN"){
						this["CURRENT_LPN"] = itemProp;
						this["ACTUAL_FROM_LPN"] = itemProp;
					}
					else if(itemProp.name() == "TO_LOC"){
						this["TO_LOC"] = itemProp;
						this["ACTUAL_TO_LOC"] = itemProp;
					}
					else if(itemProp.name() == "TO_LPN"){
						this["TO_LPN"] = itemProp;
						this["ACTUAL_TO_LPN"] = itemProp;
					}
					else if(itemProp.name() == "FROM_QTY"){
						this["FROM_QTY"] = itemProp;
						this["CONFIRM_QTY"] = itemProp;
					}
					else{
						this[itemProp.name()] = itemProp;
					}
				}
			}
		}
		
		public function ToXML():XML{
			var xmlObj:XML = 
				<TASK_DETAIL>			
					<INTERNAL_TASK_LINE_NUM>{INTERNAL_TASK_LINE_NUM}</INTERNAL_TASK_LINE_NUM>
					<INTERNAL_TASK_NUM>{INTERNAL_TASK_NUM}</INTERNAL_TASK_NUM>
					<TASK_ID>{TASK_ID}</TASK_ID>
					<TASK_TYPE>{TASK_TYPE}</TASK_TYPE>
					<WAREHOUSE>{WAREHOUSE}</WAREHOUSE>
					<COMPANY>{COMPANY}</COMPANY>
					<ITEM>{ITEM}</ITEM>
					<ITEM_DESC>{ITEM_DESC}</ITEM_DESC>
					<TOTAL_QTY>{TOTAL_QTY}</TOTAL_QTY>
					<FROM_QTY>{FROM_QTY}</FROM_QTY>
					<TO_QTY>{TO_QTY}</TO_QTY>
					<QUANTITY_UM>{QUANTITY_UM}</QUANTITY_UM>
					<FROM_LOC>{FROM_LOC}</FROM_LOC>
					<TO_LOC>{TO_LOC}</TO_LOC>
					<FROM_LPN>{FROM_LPN}</FROM_LPN>
					<TO_LPN>{TO_LPN}</TO_LPN>
					<ATTRIBUTE_NUM>{ATTRIBUTE_NUM}</ATTRIBUTE_NUM>
					<CONDITION>{CONDITION}</CONDITION>
					<REFERENCE_NUM>{REFERENCE_NUM}</REFERENCE_NUM>
					<REFERENCE_NUM_TYPE>{REFERENCE_NUM_TYPE}</REFERENCE_NUM_TYPE>
					<REFERENCE_LINE_NUM>{REFERENCE_LINE_NUM}</REFERENCE_LINE_NUM>
					<REFERENCE_ID>{REFERENCE_ID}</REFERENCE_ID>
					<ASSIGNED_USER>{ASSIGNED_USER}</ASSIGNED_USER>
					<INTERNAL_TASK_TYPE>{INTERNAL_TASK_TYPE}</INTERNAL_TASK_TYPE>
					<ATTRIBUTE1>{ATTRIBUTE1}</ATTRIBUTE1>
					<ATTRIBUTE2>{ATTRIBUTE2}</ATTRIBUTE2>
					<ATTRIBUTE3>{ATTRIBUTE3}</ATTRIBUTE3>
					<ATTRIBUTE4>{ATTRIBUTE4}</ATTRIBUTE4>
					<ATTRIBUTE5>{ATTRIBUTE5}</ATTRIBUTE5>
					<ATTRIBUTE6>{ATTRIBUTE6}</ATTRIBUTE6>
					<ATTRIBUTE7>{ATTRIBUTE7}</ATTRIBUTE7>
					<ATTRIBUTE8>{ATTRIBUTE8}</ATTRIBUTE8>
					<USER_STAMP>{USER_STAMP}</USER_STAMP>
					<DATE_TIME_STAMP>{DATE_TIME_STAMP}</DATE_TIME_STAMP>
					<INVENTORY_STS>{INVENTORY_STS}</INVENTORY_STS>
					<INTERNAL_WAVE_NUM>{INTERNAL_WAVE_NUM}</INTERNAL_WAVE_NUM>
					<REFERENCE_CONT_NUM>{REFERENCE_CONT_NUM}</REFERENCE_CONT_NUM>
					<REFERENCE_REQ_NUM>{REFERENCE_REQ_NUM}</REFERENCE_REQ_NUM>
					<CONFIRM_USER>{CONFIRM_USER}</CONFIRM_USER>
				</TASK_DETAIL>;
			return xmlObj;
		}
		
		public function ToConfirmDSXML():XML{
			var xmlObj:XML = 
				<TaskConfirmDS>			
					<INTERNAL_TASK_LINE_NUM>{INTERNAL_TASK_LINE_NUM}</INTERNAL_TASK_LINE_NUM>
					<CONFIRM_QTY>{CONFIRM_QTY}</CONFIRM_QTY>
					<QUANTITY_UM>{QUANTITY_UM}</QUANTITY_UM>
					<ACTUAL_FROM_LOC>{ACTUAL_FROM_LOC}</ACTUAL_FROM_LOC>
					<ACTUAL_FROM_LPN>{ACTUAL_FROM_LPN}</ACTUAL_FROM_LPN>
					<ACTUAL_TO_LOC>{ACTUAL_TO_LOC}</ACTUAL_TO_LOC>
					<ACTUAL_TO_LPN>{ACTUAL_TO_LPN}</ACTUAL_TO_LPN>
					<ASSIGNED_USER>{ASSIGNED_USER}</ASSIGNED_USER>
				</TaskConfirmDS>;
			return xmlObj;
		}
		

		public static function getTaskDetails(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var tskDtl:TaskDetailDO = new TaskDetailDO(xml);
				ac.addItem(tskDtl);
			}
			return ac;
		}		
	}
}